using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using GonzalesCore.CoreManagers;

namespace GonzalesCore.CoreElements
{
    public abstract class LogItemBase 
    {
        public DateTime LogDate = DateTime.MinValue;
        public SystemUser LoggedBy = null;
    }

    public class GeneralActionLogItem : LogItemBase
    {
        public string Description = "";
        public LogInterface Interface = LogInterface.System;
    }

    public class ErrorLogItem : LogItemBase
    {
        public string LogID = "";
        public string Description = "";
        public LogInterface Interface = LogInterface.System;
    }

    public class ActionLogItem : LogItemBase
    {
        public string ClaimInternalID = "";
        public string ActionDescription = "";
        public GonzalesClaimHeader.TypeOfClaimStatus ActionStatus = GonzalesClaimHeader.TypeOfClaimStatus.Null;
    }

    public class ClaimActionItem : LogItemBase
    {
        public string ClaimInternalID = "";
        public string Appr1InternalID = "";
        public string Appr1DisplayName = "";
        public string Appr1Status = "";
        public DateTime Appr1Date = DateTime.MinValue;

        public string Appr2InternalID = "";
        public string Appr2DisplayName = "";
        public string Appr2Status = "";
        public DateTime Appr2Date = DateTime.MinValue;

        public string Appr3InternalID = "";
        public string Appr3DisplayName = "";
        public string Appr3Status = "";
        public DateTime Appr3Date = DateTime.MinValue;

        public string Appr4InternalID = "";
        public string Appr4DisplayName = "";
        public string Appr4Status = "";
        public DateTime Appr4Date = DateTime.MinValue;

        public string Appr5InternalID = "";
        public string Appr5DisplayName = "";
        public string Appr5Status = "";
        public DateTime Appr5Date = DateTime.MinValue;

        public string Appr6InternalID = "";
        public string Appr6DisplayName = "";
        public string Appr6Status = "";
        public DateTime Appr6Date = DateTime.MinValue;

        public string Appr7InternalID = "";
        public string Appr7DisplayName = "";
        public string Appr7Status = "";
        public DateTime Appr7Date = DateTime.MinValue;

        public string AuthorizerInternalID = "";
        public string AuthorizerDisplayName = "";
        public string AuthorizerStatus = "";
        public DateTime AuthorizerDate = DateTime.MinValue;

        public string FAInternalID = "";
        public string FADisplayName = "";
        public string FAStatus = "";
        public DateTime FADate = DateTime.MinValue;

        public string FVInternalID = "";
        public string FVDisplayName = "";
        public string FVStatus = "";
        public DateTime FVDate = DateTime.MinValue;
    }

    public class LogsCollection : CollectionBase
    {

        public LogItemBase this[int index]
        {
            get
            {
                return ((LogItemBase)List[index]);
            }
            set
            {
                List[index] = value;
            }
        }

        public int Add(LogItemBase value)
        {
            return (List.Add(value));
        }

        public int IndexOf(LogItemBase value)
        {
            return (List.IndexOf(value));
        }

        public void Insert(int index, LogItemBase value)
        {
            List.Insert(index, value);
        }

        public void Remove(LogItemBase value)
        {
            List.Remove(value);
        }

        public bool Contains(LogItemBase value)
        {
            // If value is not of type Int16, this will return false.
            return (List.Contains(value));
        }

        public void SortByDate()
        {
            // use bubble sort
            for (int x = (this.Count - 1); x > 0; x--)
            {
                for (int y = 0; y < x; y++)
                {
                    if (this[y].LogDate.CompareTo(this[y + 1].LogDate) > 0)
                    {
                        LogItemBase Tmp = this[y];
                        this[y] = this[y + 1];
                        this[y + 1] = Tmp;
                    }
                }
            }
        }
    }
}
